<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Search
 *
 * @author yanr
 */
class Search 
{
    //put your code here
    static public function ValidAreaInSocket( $socket, $area )
    {
        $list = $socket->__get( "areas" );
        RETURN Search::ValidObjectInList($list, $user);
    }
    
    static public function ValidRoomInArea( $area, $room )
    {
        $list = $area->__get( "rooms" );
        RETURN Search::ValidObjectInList($list, $user);
    }
    
    static public function ValidUserInRoom( $room, $user )
    {
        $list = $room->__get( "users" );
        RETURN Search::ValidObjectInList($list, $user);
    }
    
    static protected function ValidObjectInList( $list, $obj )
    {
        $isFind = FALSE;
        FOR( $i = 0; $i < count( $list ); $i++ )
            IF( $list[$i] == $obj || $list[$i]->__get("id") == $obj )
            {
                $obj = $list[$i];
                $isFind = TRUE;
            }
                
        RETURN $isFind;
    }
}

?>
